package svc.elib.linkpred;

import svc.elib.db.Author;
import svc.elib.socnet.Net;

public class Salton implements LPMetric {

	@Override
	public double score(Author a, Author b, Net n) {
		CommonNeighbours cn = new CommonNeighbours();
		double com = cn.score(a, b, n);
		int aDeg = n.getGraph().degree(a);
		int bDeg = n.getGraph().degree(b);
		double denom = Math.sqrt(aDeg * bDeg);
		if (denom == 0)
			return Double.MAX_VALUE;
		return com / denom;
	}

}
